package com.train.ticket.facade.admin;

import cn.hutool.core.bean.BeanUtil;
import com.train.common.resp.CommonResp;
import com.train.common.resp.PageResp;
import com.train.dto.TicketPageDTO;
import com.train.req.TicketPageReq;
import com.train.resp.TicketPageResp;
import com.train.ticket.service.TicketService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * ticket Facade 接口
 * @author baitiaojun
 * @createDate 2025-03-14 15:17:16
 */
@RestController("adminTicketFacade")
@RequiredArgsConstructor
@RequestMapping("/admin/ticket")
public class TicketFacade {

    private final TicketService ticketService;

    @PostMapping("page")
    CommonResp pageList(@RequestBody @Validated TicketPageReq req) {
        TicketPageDTO ticketPageDTO = BeanUtil.copyProperties(req, TicketPageDTO.class);
        PageResp<TicketPageResp> pageResp = ticketService.pageList(ticketPageDTO);
        return CommonResp.ok(pageResp);
    }

    @DeleteMapping("remove/{id}")
    CommonResp delete(@PathVariable("id") Long id) {
        ticketService.remove(id);
        return CommonResp.ok();
    }
}
